﻿/*
 * Copyright 2008 Pimm Hogeling
 * 
 * This file is part of Bomberleague. Contributions to this file were made
 * by (feel free to add your name and/or e-mail to this list if you believe
 * you should be mentioned here):
 * Pimm Hogeling <pimmhogeling@gmail.com>
 * 
 * Bomberleague is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * Bomberleague is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Bomberleague. If not, see <http://www.gnu.org/licenses/>.
 */
package com.googlecode.bomberleague.events {
	import flash.events.Event;
	public class KeyEvent extends Event {
		public static const KEY:String = "keyEvent";
		public static const KEY_SET:String = "keySetEvent";
		/**
		 * The input that was used to trigger this event. This shouldn't be used in most cases.
		 */
		public var input:uint;
		/**
		 * 00-0F Keys that belong to the "Global" player.
		 * 10-1F Keys that belong to player 1.
		 * 20-2F Keys that belong to player 2.
		 * ...
		 * E0-EF Keys that belong to player 14.
		 * F0-FF Keys that belong to player 15.
		 */
		public var key:uint;
		/**
		 * The new state of the key, true for "down" and false for "up".
		 */
		public var state:Boolean;
		public function KeyEvent(type:String, key:uint, state:Boolean = true, input:uint = 0, bubbles:Boolean = false, cancelable:Boolean = false):void {
			this.key = key;
			this.state = state;
			this.input = input;
			super(type, bubbles, cancelable);
		}
		public override function clone():Event {
			return new KeyEvent(type, key, state, input, bubbles, cancelable);
		}
		public override function toString():String { 
			return formatToString("KeyEvent", "type", "key", "state", "bubbles", "cancelable", "eventPhase"); 
		}
	}
}